<template>
  <div>
    <el-table
      v-loading="$store.state.loading"
      :data="$store.state.admin.adminLog"
      style="width: 100%"
    >
      <el-table-column label="登陆时间" width="220">
        <template slot-scope="scope">
          <i class="el-icon-time"></i>
          <span style="margin-left: 10px">{{ scope.row.loginTime | date}}</span>
        </template>
      </el-table-column>
      <el-table-column label="管理员账号" width="180">
        <template slot-scope="scope">{{scope.row.adminName}}</template>
      </el-table-column>
      <el-table-column label="操作">
        <template slot-scope="scope">
          <el-button size="mini" type="danger" @click="deleteLog(scope.row._id)">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    <PageInfo action-name="getAdminLog"></PageInfo>
  </div>
</template>

<script>
export default {
  name: "adminlog",
  methods: {
    deleteLog(id) {
      console.log(id);
      this.$store.dispatch("deleteAdminLog", id).then(res => {
        if (res.ok === 1) {
          this.$store.dispatch("getAdminLog");
          this.$message({
            message: "删除成功",
            type: "success"
          });
        }
      });
    }
  }
};
</script>